﻿class PerfectNumbers

{

    static void Main()

    {

        for (int i = 2; i < 1000; i++)

        {

            int sum = 1; // 1 is always a factor

            for (int j = 2; j * j <= i; j++)

            {

                if (i % j == 0)

                {

                    sum += j;

                    if (j * j != i) // Add the corresponding factor if it's not the square root

                    {

                        sum += i / j;

                    }

                }

            }

            if (sum == i)

            {

                Console.WriteLine(i);

            }

        }

    }

}